-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Don't import helpers in namespaces #302
Conversation
6c4a75d
to
65fd5f4
Compare
@@ -174,3 +174,5 @@ def trace( | |||
'svd', 'cholesky', 'matrix_rank', 'pinv', 'matrix_norm', | |||
'matrix_transpose', 'svdvals', 'vecdot', 'vector_norm', 'diagonal', | |||
'trace'] | |||
|
|||
_all_ignore = ['math', 'normalize_axis_tuple', 'get_xp', 'np', 'isdtype'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why test_all
wasn't failing before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, test_all
is a bit brittle. At a guess, its iterating over sys.modules
is meant to be robust against renames/new private submodules in array_api_compat/*
. But then it's not easy to know if something was or was not imported.
65fd5f4
to
2c1cb6b
Compare
This is ready for review. |
@@ -276,7 +276,7 @@ def test_asarray_copy(library): | |||
is_lib_func = globals()[is_array_functions[library]] | |||
all = xp.all if library != 'dask.array' else lambda x: xp.all(x).compute() | |||
|
|||
if library == 'numpy' and xp.__version__[0] < '2' and not hasattr(xp, '_CopyMode') : | |||
if library == 'numpy' and xp.__version__[0] < '2' and not hasattr(np, "_CopyMode"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this is for numpy 1.21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. +1 for not needing a deprecation layer. Thanks @crusaderky
@@ -174,3 +174,5 @@ def trace( | |||
'svd', 'cholesky', 'matrix_rank', 'pinv', 'matrix_norm', | |||
'matrix_transpose', 'svdvals', 'vecdot', 'vector_norm', 'diagonal', | |||
'trace'] | |||
|
|||
_all_ignore = ['math', 'normalize_axis_tuple', 'get_xp', 'np', 'isdtype'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, test_all
is a bit brittle. At a guess, its iterating over sys.modules
is meant to be robust against renames/new private submodules in array_api_compat/*
. But then it's not easy to know if something was or was not imported.
Remove helper functions from wrapped array namespaces.
This was introduced when the numpy namespace was split from the helpers in 2022 (b3a12d9).
This PR prompted by a collision between
array_api_compat.device
andtorch.device
.Re. deprecation layer: unsure if we need one? This was never advertised in the documentation.